unit UPesquisaContaContabil;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, DB, DBTables, DBCtrls, Mask,
  ToolEdit;

type
  TFPesquisaRapidaContaContabil = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    DBGrid1: TDBGrid;
    QPesquisa: TQuery;
    dsPesquisa: TDataSource;
    DBText1: TDBText;
    edPesquisa: TComboEdit;
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edPesquisaButtonClick(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FPesquisaRapidaContaContabil: TFPesquisaRapidaContaContabil;

implementation

uses UGestao;

{$R *.dfm}

procedure TFPesquisaRapidaContaContabil.FormKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if key = vk_return then
    edPesquisa.Button.Click;
end;

procedure TFPesquisaRapidaContaContabil.edPesquisaButtonClick(
  Sender: TObject);
const
  ctPesquisa =
    'SELECT'#10+
    '  PLANOCONTABILIDADE.PLANOCONT_CODIGO,'#10+
    '  PLANOCONTABILIDADE.PLANOCONT_CODIGOCONTABIL,'#10+
    '  PLANOCONTABILIDADE.PLANOCONT_DESCRICAO'#10+
    'FROM'#10+
    '  PLANOCONTABILIDADE'#10+
    'WHERE'#10+
    '  PLANOCONTABILIDADE.PLANOCONT_DESCRICAO STARTING ''%s''';

begin

  QPesquisa.Close;
  QPesquisa.SQl.Clear;
  QPesquisa.SQl.Add(Format(ctPesquisa, [edPesquisa.text]));
  QPesquisa.Open;

end;

procedure TFPesquisaRapidaContaContabil.DBGrid1DblClick(Sender: TObject);
begin
  Close;
end;

end.
